package 剑指offer;

import java.util.Stack;

public class 实现栈的数据结构 {
	 
	static Stack<Integer> st=new Stack<Integer>();
    public static void push(int node) {
        st.push(node);
       
    }
    
    public static void pop() {
        st.pop();
    }
    
    public static int top() {
       return st.peek();
    }
   public static void printStack(Stack<Integer> e) {
	   while(!e.isEmpty()) {
		   System.out.println(e.pop());
	   }
   }
    public static  int min() {
    	
    	int tmp=0;
    	int min=0;
    
    	 Stack<Integer> stack = (Stack<Integer>) st.clone ();
        while(!stack.isEmpty()) {
        	tmp=stack.pop();
        	if(min==0) {
        		min=tmp;
        	}
        	else if(min>tmp) {
        		min=tmp;
        	}
        }
        return min;
    }
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		/**
		 * ["PSH3","MIN","PSH4","MIN","PSH2","MIN","PSH3","MIN","POP","MIN","POP","MIN","POP","MIN","PSH0","MIN"]
		 */
			st.push(3);
			System.out.println(min());
			 st.push(4);
			System.out.println(min());
			st.push(2);
			
			//System.out.println(min());
			st.push(3);
			//System.out.println(min());
	}

}
